package com.joinway.framework.data.jdbc.client;

import static java.lang.System.out;

import com.joinway.framework.data.jdbc.bean.ConditionItem;
import com.joinway.framework.data.jdbc.bean.Criteria;
import com.joinway.framework.data.jdbc.bean.CriteriaItem;
import com.joinway.framework.data.jdbc.bean.QueryCriteria;
import com.joinway.framework.data.jdbc.bean.SaveCriteria;

public class DataClient {

	static final String URL = "http://localhost:8080/jiayida-admin/sql/";
	
//	static final HttpClientAdaptor client = new HttpClientAdaptor()
//	
//	public static void main(String[] args){
//		test1();
//	}
//	
//	public static void test1(){
//		QueryCriteria criteria = new QueryCriteria()
//		criteria.setTable("adminUser");
////		criteria.setRawName(true);
//
//		List<ConditionItem> items = []
//		items << new ConditionItem(field:"loginName", value:"super")
//		criteria.items = items
//
//		String output = client.post(URL + "query.json", criteria)
//		out.println(output);
//	}
//	
//	public static void test2(){
//		SaveCriteria criteria = new SaveCriteria()
//		criteria.setTable("adminUser");
//
//		List<ConditionItem> items = []
//		items << new ConditionItem(field:"id", value:7)
////		criteria.items = items
//		
//		List<CriteriaItem> targets = []
//		targets << new CriteriaItem(field:"loginName", value:"jjj")
//		targets << new CriteriaItem(field:"password", value:"jjj")
//		targets << new CriteriaItem(field:"createTime", value:"current_timestamp")
//		criteria.targets = targets
//		
//		String output = client.post(URL + "save.json", criteria)
//		out.println(output);
//	}
//	
//	public static void test3(){
//		Criteria criteria = new Criteria()
//		criteria.setTable("adminUser");
//		
//		List<ConditionItem> items = []
//		items << new ConditionItem(field:"id", value:8)
//		criteria.items = items
//		
//		String output = client.post(URL + "delete.json", criteria)
//		out.println(output);
//	}
}
